package com.starbaba.mall.view;

import java.io.IOException;
import java.util.List;

import com.base.common.log.LogService;
import com.opensymphony.xwork2.ModelDriven;
import com.starbaba.core.utils.PropertyParamMapBuilder;
import com.starbaba.core.utils.Struts2Utils;
import com.starbaba.core.utils.json.JsonUtils;
import com.starbaba.core.web.page.PageResponse;
import com.starbaba.core.web.struts2.BaseAction;
import com.starbaba.mall.entity.FanliWithdrawalEntity;
import com.starbaba.mall.service.FanliOrderService;
import com.starbaba.mall.service.impl.FanliOrderServiceImpl;

/**
 * 返利提现管理action
 * @author chenweijun 2017/11/14
 *
 */
@SuppressWarnings({"serial","unchecked","rawtypes"})
public class FanliWithdrawalAction extends BaseAction implements ModelDriven<FanliWithdrawalEntity>{
	
	private FanliWithdrawalEntity model = null;
	private FanliOrderService fanliOrderservice;
	
	public FanliWithdrawalAction(){
		this.fanliOrderservice = new FanliOrderServiceImpl();
	}

	@Override
	public FanliWithdrawalEntity getModel() {
		if(model == null){
			model = new FanliWithdrawalEntity();
		}
		return model;
	}
	
	
	/**
	 * 查询提现记录列表
	 */
	public void getList(){
		
		parsePageRequest();
		PageResponse pageResponse=new PageResponse();
		paramsMap=PropertyParamMapBuilder.buildFromHttpRequest(Struts2Utils.getRequest(), paramsMap);
		
		List<FanliWithdrawalEntity> list = fanliOrderservice.getWithdrawalList(paramsMap, pageRequest.getIDisplayStart(),pageRequest.getIDisplayLength());
		int count = fanliOrderservice.countWithdrawalList(paramsMap);
		try {
			pageResponse.setITotalDisplayRecords(count);
			pageResponse.setITotalRecords(count);
			pageResponse.setAaData(list);
			sendJsonMessage(JsonUtils.toJson(pageResponse, null, true, null, false));
		} catch(IOException e) {
			LogService.error(e);
		}
		
	}

}
